﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="clr-namespace:Wpf.Controls"
    xmlns:luna="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna">

	<Style x:Key="ButtonFocusVisual">
		<Setter Property="Control.Template">
			<Setter.Value>
				<ControlTemplate>
					<Rectangle SnapsToDevicePixels="true" Margin="2" Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1"/>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0">
		<GradientStop Color="#FFFFFFFF" Offset="0"/>
		<GradientStop Color="#FFF0F0EA" Offset="0.9"/>
	</LinearGradientBrush>
	<SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF003C74"/>

	<Style x:Key="lunaNormalDropDownStyle" TargetType="{x:Type Button}">
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
		<Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
		<Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Button}">
					<Grid Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
						
						<luna:ButtonChrome x:Name="chrome" 
							BorderBrush="{TemplateBinding BorderBrush}"
							Fill="{TemplateBinding Background}"
							HorizontalAlignment="Stretch" 
							VerticalAlignment="Stretch"
							RenderMouseOver="{TemplateBinding IsMouseOver}"
							RenderPressed="{TemplateBinding IsPressed}"
							RenderDefaulted="{TemplateBinding IsDefaulted}"
							SnapsToDevicePixels="True">
							<ContentPresenter x:Name="Cp" HorizontalAlignment="Center" VerticalAlignment="Center"/>
						</luna:ButtonChrome>
						
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Path.Stroke" TargetName="Cp" Value="#ADADAD"/>
							<Setter Property="Path.Fill" TargetName="Cp" Value="#ADADAD"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style TargetType="{x:Type s:SplitButton}">
		<Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
		<Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
		<Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
		<Setter Property="HorizontalContentAlignment" Value="Center"/>
		<Setter Property="VerticalContentAlignment" Value="Center"/>
		<Setter Property="Padding" Value="1,0,1,0"/>
		
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type s:SplitButton}">
					<luna:ButtonChrome x:Name="buttonChrome" 
						HorizontalAlignment="Stretch" 
						VerticalAlignment="Stretch"
						BorderBrush="{TemplateBinding BorderBrush}"
						Fill="{TemplateBinding Background}"
						RenderMouseOver="{TemplateBinding IsMouseOver}"
						RenderPressed="{TemplateBinding IsContextMenuOpen}"
						RenderDefaulted="{TemplateBinding IsDefaulted}"
						SnapsToDevicePixels="True">

						<Grid Background="Transparent" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="*"/>
								<ColumnDefinition Width="16"/>
							</Grid.ColumnDefinitions>

							<Border x:Name="Bd" Margin="1,0,2,0">
								<ContentPresenter
									HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
									VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
									Margin="{TemplateBinding Padding}"
									RecognizesAccessKey="True"
								/>
							</Border>

							<Path x:Name="path" 
								Data="M0,0L3,3 6,0z" 
								Margin="5,1,0,0" 
								Grid.Column="1" 
								HorizontalAlignment="Center" 
								VerticalAlignment="Center" 
								Stroke="{TemplateBinding Foreground}" 
								Fill="{TemplateBinding Foreground}" 
							/>

							<Button x:Name="PART_DropDown"
								Background="{TemplateBinding Background}"
								BorderBrush="{TemplateBinding BorderBrush}"
								Foreground="{TemplateBinding Foreground}"
								VerticalAlignment="Stretch"
								Margin="0,-4,-4,-4"
								Style="{DynamicResource lunaNormalDropDownStyle}" 
								HorizontalAlignment="Stretch" 
								Grid.Column="1"
								Opacity="0"
							>

								<Path Data="M0,0L3,3 6,0z" Margin="1,1,0,0" Stroke="{TemplateBinding Foreground}" Fill="{TemplateBinding Foreground}"
									HorizontalAlignment="Center" 
									VerticalAlignment="Center"  />
							</Button>
						</Grid>
					</luna:ButtonChrome>

					<ControlTemplate.Triggers>
						<Trigger Property="Mode" Value="DropDown">
							<Setter Property="Visibility" TargetName="PART_DropDown" Value="Collapsed"/>
						</Trigger>
						<Trigger Property="Mode" Value="Button">
							<Setter Property="Visibility" TargetName="PART_DropDown" Value="Collapsed"/>
							<Setter Property="Visibility" TargetName="path" Value="Collapsed"/>
							<Setter Property="Grid.ColumnSpan" TargetName="Bd" Value="2"/>
						</Trigger>
						<Trigger Property="IsMouseOver" SourceName="PART_DropDown" Value="true">
							<Setter Property="Opacity" TargetName="PART_DropDown" Value="1"/>
						</Trigger>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Foreground" Value="#ADADAD"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>
